{%if $action == 2%}


<div>
   <form action="users.php" method="post" id="formUserProfile"><div class="fl-left">
      <!-- USER PROFILE FORM -->
      {%assign var='fields' value=$data.user->getFields()%}

      {%if isset($fields->common->fields.pics)%}
      <div class="fl-left" style="padding: 10px; border-right: 1px dotted #CCC;">
         {%$fields->common->fields.pics->getFieldHTML($data.user)%}
      </div>
      {%/if%}

      <div class="fl-left" style="padding: 10px;">
         <input type="hidden" name="a" value="2" />
         {%if !empty($data.user->id)%}<input type="hidden" name="id" value="{%$data.user->id%}" />{%/if%}
         <table>

            {%foreach from=$fields->common->fields item='field' name='i'%}
            {%if $smarty.foreach.i.first && empty($data.user->id)%}
            <tr>
               <td class="rt">
                  <label for="f_login">{%$TR->meccano->login%}<span class="warn">*</span>:</label>
               </td>
               <td>
                  <input type="text" name="f[login]" id="f_login" />
               </td>
            </tr>
            <tr>
               <td class="rt">
                  <label for="f_pwd">{%$TR->meccano->password%}<span class="warn">*</span>:</label>
               </td>
               <td>
                  <input type="password" name="p[pwd]" id="f_pwd" />
               </td>
            </tr>
            <tr>
               <td class="rt">
                  <label for="f_pwd_2">{%$TR->meccano->password_repeat%}<span class="warn">*</span>:</label>
               </td>
               <td>
                  <input type="password" name="p[pwd_2]" id="f_pwd_2" />
               </td>
            </tr>
            {%/if%}

            {%if $field->alias neq 'pics'%}
            <tr>
               <td class="rt">
                  <label for="f_{%$field->alias%}" title="{%$field->title%}">
                     {%$field->title%}
                     {%if $field->required%}<span class="warn">*</span>{%/if%}
                  </label>
               </td>
               <td>
                  {%$field->getFieldHTML($data.user)%}
               </td>
            </tr>
            {%/if%}

            {%/foreach%}

            {%foreach from=$fields->admin->fields item='field' name='i'%}
            <tr>
               <td class="rt">
                  <label for="f_{%$field->alias%}" title="{%$field->title%}">
                     {%$field->title%}
                     {%if $field->required%}<span class="warn">*</span>{%/if%}
                  </label>
               </td>
               <td>
                  {%$field->getFieldHTML($data.user)%}
               </td>
            </tr>
            {%/foreach%}

            <tr>
               <td class="rt">
                  <label>{%$TR->meccano->groups%}:</label>
               </td>
               <td>
                  {%foreach from=$data.groups item='group'%}
                  <input type="checkbox" name="f[group][]" value="{%$group.id%}" id="f_group_{%$group.id%}" {%if $data.user->isInGroup($group.id)%}checked="checked"{%/if%} />
                         <label for="f_group_{%$group.id%}"> - {%$group.group%}</label><br />
                  {%/foreach%}
               </td>
            </tr>

            <tr>
               <td></td>
               <td><input type='submit' name='commit' id='commit' value=' {%$TR->meccano->save%} ' /></td>
            </tr>
         </table>
      </div>
   </div></form>

   {%if $data.user->id && $data.user->type eq 'internal'%}
   <div class="fl-left" style="padding: 10px;">
      <!-- CHANGE USER PASSWORD FORM -->
      <form action="users.php" method="post" id="formUserPassword">
         <input type="hidden" name="id" value="{%$data.user->id%}" />
         <input type="hidden" name="a" value="2" />
         <table>
            <tr>
               <td class='rt'><label for='f_pwd_1'>{%$TR->meccano->password%}<span class="warn">*</span>:</label></td>
               <td><input type='password' name='p[pwd]' id='f_pwd' /></td>
            </tr>
            <tr>
               <td class='rt'><label for='f_pwd_2'>{%$TR->meccano->password_repeat%}<span class="warn">*</span>:</label></td>
               <td><input type='password' name='p[pwd_2]' id='f_pwd_2' /></td>
            </tr>
            <tr>
               <td></td>
               <td><input type='submit' name='commit' id='commit' value=' {%$TR->meccano->save%} ' /></td>
            </tr>
         </table>
      </form>
   </div>
   {%/if%}

   <div class="clear"></div>
</div>


<script type='text/javascript'>
   <!--
   $().ready(function(){
      {%if !$data.user->id%}
      $('#formUserProfile').validate({
         rules: {
            'f[login]': {required: true, remote: '/admin/users.php?a=3'},
            'p[pwd]': {required: true, minlength: 5},
            'p[pwd_2]': {required: true, minlength: 5, equalTo: "#f_pwd"}
         },
         messages: {
            'f[login]': {remote: '{%$TR->error->loginexist|escape:"javascript"%}'},
            'p[pwd_2]': {equalTo: "{%$TR->error->passw_neq|escape:'javascript'%}"}
         }
      });
      {%/if%}

      $('#formUserPassword').validate({
         rules: {
            'p[pwd]': {required: true, minlength: 5},
            'p[pwd_2]': {required: true, minlength: 5, equalTo: "#f_pwd"}
         },
         messages: {
            'p[pwd_2]': {equalTo: "{%$TR->error->passw_neq|escape:'javascript'%}"}
         }
      });
   });
   //-->
</script>





{%elseif $action == 11%}

<div>
   <form method='post' action='/admin/users.php' id="groupForm">
      <input type='hidden' name='a' value='11' />
      {%if $data.group%}<input type="hidden" name="id" value="{%$data.group.id%}" />{%/if%}
      <table>
         <tr>
            <td class='rt'>{%$TR->meccano->title%}<span class="warn">*</span>:</td>
            <td valign="top"><input type='text' name='f[group]' value="{%$data.group.group|default:''%}" class="required" /></td>
         </tr>
         <tr>
            <td class='rt'>{%$TR->meccano->descr%}<span class="warn">*</span>:</td>
            <td valign="top"><textarea rows='8' cols='40' name='f[descr]' class="required">{%$data.group.descr|default:''%}</textarea></td>
         </tr>
         <tr>
            <td class='rt'>{%$TR->meccano->rights%}:</td>
            <td>
               {%foreach from=$data.roles item='r'%}
               <input type="checkbox" name="f[role][]" value="{%$r.id%}" id="f_role_{%$r.id%}" {%if $data.group && in_array($r.role, $data.group.roles)%} checked="checked"{%/if%} />
               <label for="f_role_{%$r.id%}"> - {%$r.role%}</label>
               <span class="notice"> - {%$r.descr%}</span><br />
               {%/foreach%}
            </td>
         </tr>
         <tr>
            <td></td>
            <td>
               <input type='submit' name='commit' value='{%$TR->meccano->save%}' />
            </td>
         </tr>
      </table>
   </form>
</div>

<script type='text/javascript'>
   $().ready(function(){
      $('#groupForm').validate();
   });
</script>

{%/if%}